package com.film.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.film.domain.Film;
import com.film.service.FilmService;
import com.film.service.impl.FilmServiceImpl;

/**
 * gai控制类用来做头部搜索的查询
 * @author 2119196781
 *
 */
@WebServlet("/searchFilm.do")
public class SearchFilmController extends HttpServlet {
	
	private FilmService filmService = new FilmServiceImpl();
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		HttpSession session = request.getSession();
		//获得参数
		String condition = request.getParameter("kw");
		//通过条件查询
		List<Film> searchFilms = filmService.searchFilm(condition);
		session.setAttribute("searchFilms", searchFilms);
		response.sendRedirect("search.jsp");
	}
}
